package com.qyc.controller;

import com.qyc.dto.AddOrUpdateFenceHouseDTO;
import com.qyc.service.FenceHouseService;
import com.qyc.utils.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @className: FenceHouseController
 * @Description: 栏舍相关Controller层
 * @author: qinyc
 * @date: 2023/6/24 12:33
 * @version: v1.0
 */
@Api(tags = "栏舍管理")
@RestController
@RequestMapping("/fenceHouse")
public class FenceHouseController {
    //注入栏舍Service层对象
    @Autowired
    private FenceHouseService fenceHouseService;

    /**
     * @Author qinyc
     * @Description  分页多条件查询栏舍信息
     * @version: v1.0
     * @Date 12:34 2023/6/24
     **/
    @ApiOperation("分页多条件查询栏舍信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "fhName",value = "栏舍名称"),
            @ApiImplicitParam(name = "pageNum",value = "当前页码"),
            @ApiImplicitParam(name = "pageSize",value = "每页大小")
    })
    @GetMapping("/query")
    public ResponseResult queryPage(String fhName,Integer pageNum,Integer pageSize){
        return fenceHouseService.queryPage(fhName,pageNum,pageSize);
    }

    /**
     * @Author qinyc
     * @Description  根据栏舍编号查询栏舍信息以及栏圈信息
     * @version: v1.0
     * @Date 12:47 2023/6/24
     **/
    @ApiOperation("根据栏舍编号查询栏舍信息以及栏圈信息")
    @GetMapping("/selectById")
    public ResponseResult selectById(String fhId){
        return fenceHouseService.selectById(fhId);
    }

    /**
     * @Author qinyc
     * @Description 新增或修改栏舍
     * @version: v1.0
     * @Date 15:05 2023/6/24
     **/
    @ApiOperation("新增或修改栏舍")
    @PostMapping("/saveOrUpdate")
    public ResponseResult saveOrUpdate(@RequestBody AddOrUpdateFenceHouseDTO addOrUpdateFenceHouseDTO){
        return fenceHouseService.saveOrUpdate(addOrUpdateFenceHouseDTO);
    }
    
    /**
     * @Author qinyc
     * @Description  根据id删除栏舍信息
     * @version: v1.0
     * @Date 10:27 2023/6/25
     **/
    @ApiOperation("根据id删除栏舍信息")
    @DeleteMapping("/deleteById/{hId}")
    public ResponseResult deleteById(@PathVariable("hId") String hId){
        return fenceHouseService.deleteById(hId);
    }
    
    /**
     * @Author qinyc
     * @Description  批量删除栏舍
     * @version: v1.0
     * @Date 10:44 2023/6/25
     **/
    @ApiOperation("批量删除栏舍")
    @DeleteMapping("/deleteByIdAll")
    public ResponseResult deleteByIdAll(@RequestBody List<String> hIds){
        return fenceHouseService.deleteByIdAll(hIds);
    }
}
